# coding: utf-8
import sqlite3
import uuid

db_path = 'db.sqlite3'
conn = sqlite3.connect(db_path)
cursor = conn.cursor()

print("Current users:")
cursor.execute("SELECT phone FROM Server_user")
users = cursor.fetchall()
for u in users:
    print("  Phone:", u[0])

# Add user 13088888888
phone = '13088888888'
cursor.execute("SELECT id FROM Server_user WHERE phone = ?", (phone,))
if cursor.fetchone():
    print("\nPhone %s already exists" % phone)
else:
    print("\nAdding phone %s..." % phone)
    user_id = str(uuid.uuid4())
    cursor.execute("""
        INSERT INTO Server_user (id, username, password, phone, head_portrait, is_admin, money)
        VALUES (?, ?, ?, ?, ?, ?, ?)
    """, (user_id, 'testuser', 'pbkdf2_sha256$600000$test$test', phone, '', 0, 1000.0))
    conn.commit()
    print("SUCCESS! User created.")

conn.close()
print("\nDone! You can now login with phone: %s" % phone)

